## Table A11: Effects of Changes in Lagged Differential Demand on Mean Wait Times

## install.packages(c("tidyverse", "fixest"))
## library(tidyverse)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("demand.RData")

## Column 1
race_wait_demand_lag <- feols(log_mean_wait ~ lag_non_white_demand |
                                city_service + open_month^open_year, 
                              data = demand, 
                              weights = demand$tot_calls)

## Column 2
race_wait_need_lag <- feols(log_mean_wait ~ lag_non_white_need |
                              city_service + open_month^open_year, 
                            data = demand, 
                            weights = demand$tot_calls)

## Column 3
income_wait_demand_lag <- feols(log_mean_wait ~ lag_poor_demand |
                                  city_service + open_month^open_year, 
                                data = demand, 
                                weights = demand$tot_calls)

## Column 4
income_wait_need_lag <- feols(log_mean_wait ~ lag_poor_need |
                                city_service + open_month^open_year, 
                              data = demand, 
                              weights = demand$tot_calls)

## Column 5
race_expected_demand_lag <- feols(log_mean_expected ~ lag_non_white_demand |
                                    city_service + open_month^open_year, 
                                  data = demand, 
                                  weights = demand$tot_calls)

## Column 6
race_expected_need_lag <- feols(log_mean_expected ~ lag_non_white_need |
                                  city_service + open_month^open_year, 
                                data = demand, 
                                weights = demand$tot_calls)

## Column 7
income_expected_demand_lag <- feols(log_mean_expected ~ lag_poor_demand |
                                      city_service + open_month^open_year, 
                                    data = demand, 
                                    weights = demand$tot_calls)

## Column 8
income_expected_need_lag <- feols(log_mean_expected ~ lag_poor_need |
                                    city_service + open_month^open_year, 
                                  data = demand, 
                                  weights = demand$tot_calls)

TableA11 = etable(race_wait_demand_lag, race_wait_need_lag,
                  income_wait_demand_lag, income_wait_need_lag,
                  race_expected_demand_lag, race_expected_need_lag,
                  income_expected_demand_lag, income_expected_need_lag,
                  signifCode = c("+" = 0.10, "*" = 0.05, "**" = 0.01, "***" = 0.001),
                  digits = 3, digits.stats = 3, fitstat = c("n","r2"))